from frontend.roleApplication import RoleApplication
from frontend.form import Type
from vars import *

class CustomerApplication(RoleApplication):

    def __init__(self):
        super(CustomerApplication, self).__init__(WorkflowName, Role.Customer)
        # Here we use SOURCE step.  This means this role will be used to begin our workflow
        self.register_source_step(Step.PlaceOrder, self.generic_starter_role_form_creator)
        self.register_sink_step(Step.ChooseBackorder, self.backorder_form_creator, name_fields=['PillowType','PillowQuantity'])
        
    def generic_starter_role_form_creator(self, stepname, form):
        form.add_static_label('                                      Order Form')
        form.add_static_label('Ostrich Pillow---------------------------------------------$99.00')
        form.add_static_label('A cave-like micro environment in which to take a warm and comfortable power nap at ease. It is a pillow, cushion, bed and garment all at the same time.')
        form.add_static_label('Boyfriend Pillow (Dream Man Arm)---------------------$24.99')
        form.add_static_label('The Boyfriend Arm Pillow is a uniquely designed memory foam arm pillow that gives you the feeling of being embraced by a real man without the snoring.')
        form.add_static_label('Girlfriend Pillow--------------------------------------------$35.00')
        form.add_static_label('Huffington Post said this is the saddest \'Human Being Substitute You Can Buy\'.')
        form.add_static_label('Baby Hands Pillow----------------------------------------$44.95')
        form.add_static_label('Babies are used to the warm comfort and protection of their mother\'s womb and the Baby Hands Pillow can help imitate that feeling as it provides similar support.')
        form.add_static_label('George Wyner Pillow-------------------------------------$450.00')
        form.add_static_label('A premium pillow for the coder in everybody made out of silk and dreams.')
        form.add_field(Type.CHOICE, 'PillowType',labeltext="Pillow Type: ",choices=['Ostrich Pillow','Boyfriend Pillow','Girlfriend Pillow','Baby Hands Pillow','George Wyner Pillow'])
        form.add_field(Type.INTEGER,'PillowQuantity',labeltext="Pillow Quantity")
        form.add_field(Type.SHORTSTRING,'AddressName',labeltext="Enter Full Name")
        form.add_field(Type.SHORTSTRING,'AddressStreet',labeltext="Street Address")
        form.add_field(Type.SHORTSTRING,'AddressCity',labeltext="City")
        form.add_field(Type.SHORTSTRING,'AddressState',labeltext="State")
        form.add_field(Type.SHORTSTRING,'AddressZipcode',labeltext="Zip Code")
        
    def backorder_form_creator(self, stepname, form):
        form.add_task_label(fields=['PillowType','PillowQuantity'])
        form.add_static_label("We're sorry, the item(s) you have ordered are not in stock. Would you like to place a backorder?")
        form.add_field(Type.CHOICE, 'Backorder',labeltext="Place backorder?",choices=['Yes','No'])
        
if __name__ == '__main__':
    app = CustomerApplication()
    app.MainLoop()